package br.mg.bhe.ftpobre.fs;

import java.io.File;

/**
 * 
 * @author Aureliano
 */
public final class OpenFileManager {

	private OpenFileManager() {
		super();
	}
	
	public static void openFile(String path) {
		IOpenFile strategy = getOpenFileStrategy();
		open(strategy, new File(path));
	}
	
	private static void open(IOpenFile strategy, File file) {
		strategy.open(file);
	}
	
	private static IOpenFile getOpenFileStrategy() {
		OperationalSystem os = OperationalSystem
			.getOsFromString(System.getProperty("os.name"));
		
		switch (os) {
			case LINUX   :
				return new OpenLinuxFile();
			case WINDOWS :
				return new OpenWindowsFile();
			default 	 :
				throw new IllegalAccessError("Sistema Operacional  " + os + " não suportado!");
		}
	}
}